package com.mingqijia.gassafety.authority.api.web.facade;

import com.mingqijia.gassafety.authority.api.req.department.CreateDepartmentReqDTO;
import com.mingqijia.gassafety.authority.api.req.department.QueryDepartmentReqDTO;
import com.mingqijia.gassafety.authority.api.req.department.UpdateDepartmentReqDTO;
import com.mingqijia.gassafety.authority.api.resp.department.DepartmentRespDTO;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * REST接口
 * @author Damon S.
 * @version v0.2
 * @date 2021-06-19
 */
@Api(tags = "控制台--部门")
@RequestMapping(value = "/console/v1/hierarchies", produces = MediaType.APPLICATION_JSON_VALUE)
public interface DepartmentManageFacade {

    @GetMapping("/departments")
    @ApiOperation(value = "获取企业部门树形结构", notes = "返回当前企业下的部门列表")
    PageUtil<DepartmentRespDTO> findDepartment(@RequestParam String usage);

    @GetMapping
    @ApiOperation(value = "查询部门", notes = "返回部门列表")
    PageUtil<DepartmentRespDTO> findDepartment(@Valid QueryDepartmentReqDTO req);

    @PostMapping
    @ApiOperation(value = "新增部门", notes = "返回是否新增成功")
    String createDepartment(@RequestBody@Valid CreateDepartmentReqDTO req);

    @PutMapping
    @ApiOperation(value = "编辑部门", notes = "返回是否编辑成功")
    void updateDepartment(@RequestBody@Valid UpdateDepartmentReqDTO req);

    @DeleteMapping
    @ApiImplicitParam(name = "orgId", value = "部门Id列表", dataType = "Array")
    @ApiOperation(value = "删除部门", notes = "返回是否删除成功")
    void removeDepartment(String[] orgId);


    @PutMapping("/{orgId}/{state}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orgId", value = "部门Id", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "启用状态", dataType = "String")
    })
    @ApiOperation(value = "部门上下线(0停用，1启用)", notes = "返回是否成功")
    void switchDepartment(@PathVariable String orgId, @PathVariable Integer state);
}
